import request from '@/utils/request'

// 客户
export function getCustomers(params) {
  // 映射前端参数为后端所需参数
  const query = {
    name: params.name,
    phone: params.phone,
    petName: params.petName,
    petBreed: params.petBreed,
    pageNum: params.pageNum,
    pageSize: params.pageSize
  };
  console.log('[API] getCustomers 请求参数:', query);
  return request.get('/client-pet/customers/page-list', { params: query }).then(res => {
    console.log('[API] getCustomers 返回:', res);
    return res;
  });
}
export function addCustomer(data) {
  console.log('[API] addCustomer 请求参数:', data);
  return request.post('/client-pet/customers', data).then(res => {
    console.log('[API] addCustomer 返回:', res);
    return res;
  });
}
export function updateCustomer(id, data) {
  console.log('[API] updateCustomer 请求参数:', id, data);
  return request.put(`/client-pet/customers/${id}`, data).then(res => {
    console.log('[API] updateCustomer 返回:', res);
    return res;
  });
}
export function deleteCustomer(id) {
  console.log('[API] deleteCustomer 请求参数:', id);
  return request.delete(`/client-pet/customers/${id}`).then(res => {
    console.log('[API] deleteCustomer 返回:', res);
    return res;
  });
}

// 宠物
export function addPet(customerId, data) {
  return request.post(`/client-pet/customers/${customerId}/pets`, data)
}
export function updatePet(id, data) {
  return request.put(`/client-pet/pets/${id}`, data)
}
export function deletePet(id) {
  return request.delete(`/client-pet/pets/${id}`)
}

// 疫苗
export function addVaccine(data) {
  return request.post('/client-pet/customer/vaccine/add', data)
}
export function updateVaccine(data) {
  return request.put('/client-pet/customer/vaccine/update', data)
}
export function deleteVaccine(id) {
  return request.delete(`/client-pet/customer/vaccine/delete/${id}`)
}

// 关怀
export function getCareList(params) {
  return request.get('/client-pet/customer/care/list', { params })
}
export function addCare(data) {
  return request.post('/client-pet/customer/care/add', data)
}
export function updateCare(data) {
  return request.put('/client-pet/customer/care/update', data)
}
export function deleteCare(id) {
  return request.delete(`/client-pet/customer/care/delete/${id}`)
}
export function sendCare(id) {
  return request.post(`/client-pet/customer/care/send/${id}`)
}
export function batchGenerateCare(data) {
  return request.post('/client-pet/customer/care/batch-generate', data)
}

// 升级会员
export function upgradeMember(data) {
  return request.post('/client-pet/customer/upgrade', data)
} 